package function

object Function2 {
  def main(args: Array[String]): Unit = {
    //    def sayHi(name:String):Unit={
    //      println("hi,",name);
    //    }
    sayHi("张三")
    println(f(2,4))

    def f(a: Int, b: Int): Int = {
     a+b
    }
    //可变参数在参数类型后面加上*
    def f1(str:String*):Unit={
      println(str)
    }
    f1("里斯")
    f1("riaca","dfd")
    def f2(name:String,age:Int):Unit={
      println(s"${age}岁的${name}在there")
    }
    f2("luis",23)
    //函数的简化原则
    def f3(name:String)= name
    println(f3("简化"))

    def f4(name:String):Unit={
      println(name)
    }
          f4("lalla")
    //匿名函数申明：把函数名去掉，只留下函数的参数，等号变成=>
    (name:String)=>{println(name)}

  }
  def sayHi(name: String): Unit = {
    println("Hi", name);
  }
}
